﻿using GroupMeal.Foods;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
using Volo.Abp.AspNetCore.Mvc;

namespace GroupMeal.Web.Controllers
{
    public class FoodTypeController(IFoodTypeAppService foodTypeAppService) : AbpController
    {
        private readonly IFoodTypeAppService _foodTypeAppService=foodTypeAppService;

        [HttpGet("/api/food-type/get-list")]
        public async Task<IActionResult> GetFoodTypeList(string filterName)
        {
            return new JsonResult(await _foodTypeAppService.GetList(filterName));
        }

        [HttpGet("/api/food-type/get-detail")]
        public async Task<IActionResult> GetDetail(Guid id)
        {
            return new JsonResult(await _foodTypeAppService.GetDetail(id));
        }

        [HttpPost("/api/food-type/create")]
        public async Task<IActionResult> Create([FromBody] CreateFoodTypeDto dto)
        {
            return new JsonResult(await _foodTypeAppService.Create(dto));
        }

        [HttpGet("/api/food-type/delete")]
        public async Task<IActionResult> Delete(Guid id)
        {
            return new JsonResult(await _foodTypeAppService.Delete(id));
        }

        [HttpPost("/api/food-type/edit")]
        public async Task<IActionResult> Edit([FromBody] FoodTypeDto dto)
        {
            return new JsonResult(await _foodTypeAppService.Edit(dto));
        }
    }
}
